#include "syscall.h"
#include "stdio.h"
#include "stdlib.h"

#define BUFSIZE 1024
#define DEF_FILE nachos.conf

char buf[BUFSIZE];

int main(int argc, char** argv)
{
  int fd, amount;
  char* file;

  if (argc!=2) {
    printf("Usage: cat <file>\n");
    file = "nachos.conf";
  } else {
     file = argv[1];
  }
  printf(" using %s\n", file );

  fd = open(file);
  if (fd==-1) {
    printf("Unable to open %s\n", file);
    return 1;
  }

  while ((amount = read(fd, buf, BUFSIZE))>0) {
    //write(1, buf, amount);
    printf(buf);
  }

  close(fd);

  return 0;
}
